/*
 * @lc app=leetcode.cn id=657 lang=cpp
 *
 * [657] 机器人能否返回原点
 */

// @lc code=start
class Solution
{
public:
  bool judgeCircle(string moves)
  {
    int R = 0, L = 0, U = 0, D = 0;
    for (char& c : moves) {
      switch (c) {
        case 'R': ++R; break;
        case 'L': --L; break;
        case 'U': ++U; break;
        case 'D': --D; break;
      }
    }
    return R + L == 0 && U + D == 0;
  }
};
// @lc code=end
